// pages/exercises/exercisesHome/exercisesHome.js
var app = getApp();
var config = require('../../../../config.js');
const http = require('../../../../http.js')
var fromType = -1;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    itemList:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    fromType = options.fromType;
    console.log("fromType==="+fromType);
    this.getList();
 
  },

  getList:function(){
    var that = this;
    http.request(
      config.getExercisesList,
      'POST',null,
      function (res) {
          var list = res.rows;
          //设置集合
          that.setData({
            itemList: list
          })
        
      },
      function (err) {
        wx.showToast({
          title: err,
          icon: 'none',
        })
      }, true
    )

  },
  //获取列表数据
  // getList: function () {
  //   var that = this;
  //   console.log('id' + app.globalData.openid)
  //   wx.request({
  //     url: config.getExercisesList,
  //     method: "POST",
  //     data: {
  //       // openId: wx.getStorageSync('sessionId'),
  //       openId: app.globalData.openid,
  //       type:fromType
  //     },
  //     success: function (ret) {
  //       var data = ret.data
  //       if (data.success == 0) {
  //         console.log(data);
  //         var list = data.rows;
  //         //设置集合
  //         that.setData({
  //           itemList: list
  //         })
  //       }
  //     }
  //   })
  // },

  //  跳转详情
  toDetails: function (event) {
    var detailsId = event.currentTarget.dataset.bankid;
    // if (!app.globalData.userInfo) {
    //   console.log("判断是否授权，否则打开授权");
    //   //未授权
    //   wx.navigateTo({
    //     url: '../authorization/authorization?pageId=' + config.exercises
    //   })
    //   return;
    // }
    wx.navigateTo({
      url: '../exercisesDetail/exercisesDetail?bankId=' + detailsId
    })
  },












  
})